Kinetis SDK Demo Applications User Guide  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Shell Test Demo User Guide

User guide on how to customize this application for different configurations. More...

Shell Test Demo User Guide

Getting Started

To get started, perform following steps:

  1. Download the program to a target board.
  2. Connect the USB cable to a PC host and open a serial terminal at 115200 baud, 8-bits no parity, 1 stop bit.
  3. Reset the board, after that, shell welcome information will be displayed on terminal. you can type "help" for more information. Communication Interface Settings:
  • TWR-K64F120M(OpenSDA) UART1 TX: PC3 RX: PC4.
  • FRDM-K64F120M(OpenSDA) UART0 TX: PC17 RX: PC16.

HOWTO Customization

You can customize shell system and register your command to shell. Those macro located in shell_config.h.

Functional configuration

to enable shell auto complete support, use the following:

#define SHELL_CONFIG_AUTO_COMPLETE /* config if use auto complete */

to enable shell history support, use the following:

#define SHELL_CONFIG_USE_STDIO /* config if use auto complete */

use this macro to configure if stdout will be connected to shell input and output.

#define SHELL_CONFIG_USE_STDIO /* config if use standard output */

Configure consult and history record buffer size

Change the following macro to configure characters for read line input. generally HIST_SIZE should be equal to SHELL_CB_SIZE

#define SHELL_CB_SIZE (128)
#define HIST_SIZE SHELL_CB_SIZE

Configure max numbers of commands and command arguments

Change the following macro to configure max arguments for all commands.

#define SHELL_MAX_ARGS (8)

Change the following macro to configure max function number

#define SHELL_MAX_FUNCTION_NUM (64)

Add command

To register your own function to the mini shell, perform those steps:

  1. Define a command function table and fill in the table with register information.
  2. Two ways to register your command to shell:
use shell_register_function(const cmd_tbl_t * pAddress) to register single commands.
use shell_register_function_array(const cmd_tbl_t * pAddress, uint8_t num) to register mutilple commands.
command function table struct is located in shell.h. as follow:

typedef struct
{
char *name; /* command Name */
uint8_t maxargs; /* maximum number of arguments */
uint8_t repeatable; /* autorepeat allowed? */
int (*cmd)(int argc, char * const argv[]); /* Implementation function */
char *usage; /* Usage message (short) */
char *help; /* Help message (long) */
int (*complete)(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]); /* do auto completion on the arguments */

Example for register command struct

static const cmd_tbl_t CommandFun_Test =
{
.name = "test",
.maxargs = 5,
.repeatable = 1,
.cmd = DoTest,
.usage = "help - app test function",
.complete = NULL,
.help = "long help - app test function",
};